package com.nowcoder.community.util;

import com.nowcoder.community.entity.User;
import org.springframework.stereotype.Component;

/**
 * 线程储存用户数据
 */
@Component
public class HostHolder {
    private ThreadLocal<User> localUser = new ThreadLocal<>();
    public void setUser (User user){
        localUser.set(user);
    }
    public User getUser(){
        return localUser.get();
    }
    public void clean(){
        localUser.remove();
    }
}
